# include <bits/stdc++.h>
using namespace std;

struct list_node{
    int val;
    struct list_node * next;
};

list_node * input_list(void)
{
    int n, val;
    list_node * phead = new list_node();
    list_node * cur_pnode = phead;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &val);
        if (i == 1) {
            cur_pnode->val = val;
            cur_pnode->next = NULL;
        }
        else {
            list_node * new_pnode = new list_node();
            new_pnode->val = val;
            new_pnode->next = NULL;
            cur_pnode->next = new_pnode;
            cur_pnode = new_pnode;
        }
    }
    return phead;
}

list_node* ReveserList(list_node* RHead)
{
    list_node* prev = nullptr;
    list_node* cur = RHead;
    while(cur)
    {
        list_node* next = cur->next;
        //反转
        cur->next = prev;
        //更新prev和cur，继续向后迭代反转
        prev = cur;
        cur = next;
    }
    return prev;
}


list_node * reverse_list(list_node * head, int L, int R)
{
    //先创建一个虚拟头节点
    list_node* pHead = new list_node;
    pHead->next = head;
    list_node* prevNode = pHead;
    list_node* RHead = nullptr;
    list_node* RTail = nullptr;
    list_node* nextNode = nullptr;
    
    //找到反转部分链表的前一个节点
    for(int i = 0;i < L-1;i++)
    {
        prevNode = prevNode->next;
    }
    RHead = prevNode->next;
    //找到反转链表的尾节点
    RTail = RHead;
    for(int i = 0;i < R-L;i++)
    {
        RTail = RTail->next;
    }
    nextNode = RTail->next;
    
    //需要将RTail->next = nullptr;
    RTail->next = nullptr;
    list_node* newHead = ReveserList(RHead);
    //恢复链接
    prevNode->next = newHead;
    RHead->next = nextNode;
    list_node* list = pHead->next;
    delete pHead;
    return list;

}

void print_list(list_node * head)
{
    while (head != NULL) {
        printf("%d ", head->val);
        head = head->next;
    }
    puts("");
}


int main ()
{
    int L, R;
    list_node * head = input_list();
    scanf("%d%d", &L, &R);
    list_node * new_head = reverse_list(head, L, R);
    print_list(new_head);
    return 0;
}
